home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / textwndw.swg / 0019_Windowing Routines.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-02-28  |  3.2 KB  |  155 lines

  1.  
  2. unit testwin2;
  3.  
  4. interface
  5. uses crt;
  6. procedure Popbox(x1,y1,x2,y2,UPborder,DNborder,Back: byte);
  7. procedure CloseBox;
  8. Procedure SaveScreen;
  9. Procedure RestoreScreen;
  10. procedure Cursoron;
  11. procedure Cursoroff;
  12. type
  13.  windowtype = record
  14.                x1,x2,y1,y2: byte;
  15.                scrsave: array[1..4096] of byte;
  16.               end;
  17.  scrarray= array[0..3999] of byte;
  18.  scrptr= ^scrarray;
  19.  AScreen = Array[1..4000] of Byte;
  20. const
  21.  screenbase: word =$B800;
  22. var
  23.  Screen: scrarray Absolute $B800:$0;
  24.  numwindows: byte;
  25.  ws: array[1..3] of windowtype;
  26.  scr1,scr2,scr3: scrptr;
  27.  P : ^AScreen;    {Pointer to the Array}
  28.  Scr : AScreen;
  29.  CursorType : word;
  30.  
  31. implementation
  32.  
  33. procedure Cursoroff; assembler;
  34.  
  35.     asm
  36.         mov ah, 03h
  37.         mov bh, 00h
  38.         int 10h
  39.         mov CursorType, cx
  40.         mov ah, 01h
  41.         mov cx, 65535
  42.         int 10h
  43.     end;
  44.  
  45. procedure Cursoron; assembler;
  46.  
  47.     asm
  48.         mov ah, 01h
  49.         mov cx, CursorType
  50.         int 10h
  51.     end;
  52.  
  53. Procedure SaveScreen;
  54. begin
  55.   P := Ptr($B800,$0); {Point to video memory}
  56.   Move(P^,Scr,4000);  {Move the screen into the Array}
  57. end;
  58.  
  59. Procedure RestoreScreen;
  60. begin
  61.   Move(Scr,MEm[$B800 : 0], 4000); {Move the saved screen to video mem}
  62. end;
  63.  
  64. procedure Popbox(x1,y1,x2,y2,UPborder,DNborder,back: byte);
  65. var
  66.  x,y: byte;
  67. begin;
  68.  window(1,1,80,25);
  69.  textcolor(UPborder);
  70.  textbackground(Back);
  71.  gotoxy(x1,y1);
  72.  for x:=x1+1 to x2 do write('─');
  73.  textcolor(dnborder);
  74.  gotoxy(x1,y2);
  75.  for x:=x1+1 to x2 do write('─');
  76.  for y:=y1+1 to y2-1 do begin;
  77.   textcolor(upborder);
  78.   gotoxy(x1,y);
  79.   write('│');
  80.   textcolor(dnborder);
  81.   gotoxy(x2,y);
  82.   write('│');
  83.  end;
  84.  textcolor(upborder);
  85.  gotoxy(x1,y1);
  86.  write('┌');
  87.  textcolor(dnborder);
  88.  gotoxy(x2,y1);
  89.  write('┐');
  90.  textcolor(upborder);
  91.  gotoxy(x1,y2);
  92.  write('└');
  93.  textcolor(dnborder);
  94.  gotoxy(x2,y2);
  95.  write('┘');
  96.  inc(numwindows);
  97.  ws[numwindows].x1:=lo(windmin)+1;
  98.  ws[numwindows].x2:=lo(windmax)+1;
  99.  ws[numwindows].y1:=hi(windmin)+1;
  100.  ws[numwindows].y2:=hi(windmax)+1;
  101.  move(mem[screenbase:0000],ws[numwindows].scrsave,4096);
  102.  window(x1+1,y1+1,x2-1,y2-1);
  103.  clrscr;
  104.  gotoxy(1,1);
  105. end;
  106.  
  107. procedure CloseBox;
  108.  
  109. begin;
  110.  move(ws[numwindows].scrsave,mem[screenbase:0000],4096);
  111.  window(ws[numwindows].x1,ws[numwindows].y1,ws[numwindows].x2, {editor wrap}
  112.                                                           ws[numwindows].y2);
  113.  dec(numwindows);
  114. end;
  115. end.
  116.  
  117. { ------------------------------   DEMO PROGRAM  ---------------------- }
  118.  
  119. Program Demo_for_testwin2;
  120.  
  121. uses crt,testwin2;
  122. begin;
  123.  cursoroff;
  124.  new(scr1);
  125.  new(scr2);
  126.  textcolor(0);
  127.  textbackground(7);
  128.  clrscr;
  129. gotoxy(30,12);
  130. write('Main Screen');
  131. savescreen;
  132.  readkey;
  133.  Popbox(17,9,62,17,15,0,3);
  134.  writeln('     Window one');
  135.  move(mem[screenbase:0000],scr1^,4096);
  136.  readkey;
  137.  Popbox(25,3,40,22,10,0,2);
  138.  writeln('Window two');
  139.  move(mem[screenbase:0000],scr2^,4096);
  140.  readkey;
  141.  Popbox(8,12,65,20,12,0,4);
  142.  writeln('Window three');
  143.  readkey;
  144.  CloseBox;
  145.  move(scr2^,mem[screenbase:0000],4096);
  146.  readkey;
  147.  CloseBox;
  148.  move(scr1^,mem[screenbase:0000],4096);
  149.  readkey;
  150.  restorescreen;
  151.  readkey;
  152.   cursoron;
  153.  end.
  154.  
  155.